<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<button id="btn1"></button>
</body>
<script>
    btn1.onclick=function(){
      var pos=navigator.geolocation.getCurrentPosition(successCB,errCB);
    }
    function successCB(pos) {
        console.log("success");
        console.log("定位时间"+pos.timestamp);
        console.log("维度"+pos.coords.latitude);
        console.log("经度"+pos.coords.longitude);
        console.log("海拔"+pos.coords.altitude);
        console.log("速度"+pos.coords.speed);

    }
    function errCB(err){
        console.log(err.code);
        console.log(err.message);
        console.log("获取失败");
    }
</script>

</html>